/*
 * @Author: 0x9DEFA478
 * @Date: 2021-03-11 17:53:34
 * @LastEditTime: 2025-07-26 21:20:26
 * @LastEditors: 0x9DEFA478
 * @Description: 自定义类型
 * 
 */
#ifndef hH_Type_H_
#define hH_Type_H_
#include "./Config/H_Config.h"
#ifdef __cplusplus
extern "C"{
#endif

#if vH_Config_TypeUseSTD
#include <stdint.h>
#include <stddef.h>
#ifndef tH_Type_INT8
#define tH_Type_INT8                                              int8_t
#endif
#ifndef tH_Type_UINT8
#define tH_Type_UINT8                                             uint8_t
#endif
#ifndef tH_Type_INT16
#define tH_Type_INT16                                             int16_t
#endif
#ifndef tH_Type_UINT16
#define tH_Type_UINT16                                            uint16_t
#endif
#ifndef tH_Type_INT32
#define tH_Type_INT32                                             int32_t
#endif
#ifndef tH_Type_UINT32
#define tH_Type_UINT32                                            uint32_t
#endif
#ifndef tH_Type_INT64
#define tH_Type_INT64                                             int64_t
#endif
#ifndef tH_Type_UINT64
#define tH_Type_UINT64                                            uint64_t
#endif
#ifndef tH_Type_INT
#define tH_Type_INT                                               signed int
#endif
#ifndef tH_Type_UINT
#define tH_Type_UINT                                              unsigned int
#endif
#define tH_Type_PTRDIFF                                           ptrdiff_t
#endif




typedef tH_Type_INT8                                              Hint8;
typedef tH_Type_UINT8                                             Hbyte;

typedef tH_Type_INT16                                             Hint16;
typedef tH_Type_UINT16                                            Huint16;

typedef tH_Type_INT32                                             Hint32;
typedef tH_Type_UINT32                                            Huint32;

typedef tH_Type_INT64                                             Hint64;
typedef tH_Type_UINT64                                            Huint64;


typedef Hint16                                                    Char16;
typedef Hint32                                                    Char32;


#if vH_Config_PointerSize == 1
//与(void*) 占用空间相同的整型
typedef Hint8                                                     Hintptr;
//与(void*) 占用空间相同的无符号整型
typedef Hbyte                                                     Huintptr;
#elif vH_Config_PointerSize == 2
//与(void*) 占用空间相同的整型
typedef Hint16                                                    Hintptr;
//与(void*) 占用空间相同的无符号整型
typedef Huint16                                                   Huintptr;
#elif vH_Config_PointerSize == 4
//与(void*) 占用空间相同的整型
typedef Hint32                                                    Hintptr;
//与(void*) 占用空间相同的无符号整型
typedef Huint32                                                   Huintptr;
#elif vH_Config_PointerSize == 8
//与(void*) 占用空间相同的整型
typedef Hint64                                                    Hintptr;
//与(void*) 占用空间相同的无符号整型
typedef Huint64                                                   Huintptr;
#else
#error "没有为Hintptr与Huintptr找到合适的类型"
#endif

//用于表示大小的类型
typedef Hintptr                                                   Hsize;
//用于表示大小的类型
typedef Huintptr                                                  Husize;

#ifndef tH_Type_PTRDIFF
#define tH_Type_PTRDIFF                                           Hsize
#endif
typedef tH_Type_PTRDIFF                                           Hptrdiff;

#if vH_Config_FunctionPointerSize == 1
//与(void (*)(void)) 占用空间相同的整型
typedef Huint8                                                    Hfunctionptr;
#elif vH_Config_FunctionPointerSize == 2
typedef Huint16                                                   Hfunctionptr;
#elif vH_Config_FunctionPointerSize == 4
typedef Huint32                                                   Hfunctionptr;
#elif vH_Config_FunctionPointerSize == 8
typedef Huint64                                                   Hfunctionptr;
#else
#error "没有为Hfunctionptr找到合适的类型"
#endif




#ifndef NULL
#define NULL                                                      0
#endif

#ifndef cH_IsNull
#define cH_IsNull(Ptr)                                            ((Ptr)==NULL)
#endif

#define cH_GetParentPointer(in_ItemPtr,in_Type,in_ItemName)       ((in_Type*)(((Hbyte*)in_ItemPtr)-(Hsize)&(((in_Type*)0)->in_ItemName)))
#define cH_GetConstParentPointer(in_ItemPtr,in_Type,in_ItemName)  ((const in_Type*)(((const Hbyte*)in_ItemPtr)-(Hsize)&(((in_Type*)0)->in_ItemName)))




#ifndef tH_StringFormat_long_double
#define tH_StringFormat_long_double                               long double
#endif
typedef tH_StringFormat_long_double                               Hlongdouble;




#ifdef __GNUC__
#define CheckPrintfFormat(in_FormatIndex,in_ParamIndex) __attribute__((__format__(gnu_printf,in_FormatIndex+1,in_ParamIndex+1)))
#else
#define CheckPrintfFormat(in_FormatIndex,in_ParamIndex)
#endif




#ifdef __cplusplus
}
#endif
#endif // !hH_Type_H_
